<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<title>部门管理</title>
		<link rel="stylesheet" th:href="@{~/component/pear/css/pear.css}" media="all">
		<link rel="stylesheet" th:href="@{~/admin/css/other/department.css}" media="all">
	</head>
	<body >

		<div class="layui-row ">
			<div class="layui-col-md12">
				<div class="layui-card-body">
						<div id="organizationTreeContent" style="overflow: auto">
							<ul id="organizationTree" class="dtree organizationTree" data-id="9527"></ul>
						</div>
					</div>
			</div>
			
		</div>
		<div class="bottom">
	        <div class="button-container">
	            <button id="confirm"  class="layui-btn layui-btn-normal layui-btn-sm" >
	                <i class="layui-icon layui-icon-ok"></i>确定
	            </button>
	        </div>
    	</div>

		<script src="../../../../component/layui/layui.js"></script>
		<script src="../../../../component/pear/pear.js"></script>
		<script>
			layui.use(['table', 'form', 'jquery', 'dtree'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let dtree = layui.dtree;

				let MODULE_PATH = "operate/";
				
				let dept = null;

				var DTree = dtree.render({
					elem: "#organizationTree",
					//data: data,
					initLevel: "2", //默认展开层级为1
					line: true, // 有线树
					ficon: ["1", "-1"], // 设定一级图标样式。0表示方形加减图标，8表示小圆点图标
					icon: ["0", "7"], // 设定二级图标样式。0表示文件夹图标，5表示叶子图标
					method: 'get',
					url: "../../../../admin/data/organizationtree.json"
				});

				// 绑定节点点击事件
				dtree.on("node(organizationTree)", function(obj) {
					dept = obj.param;
					if (!obj.param.leaf) {
						var $div = obj.dom;
						DTree.clickSpread($div); //调用内置函数展开节点
					} else {
						console.log('已展开到最终节点');
						
					}
				});
				
				// 点击确认按钮
				$("#confirm").on("click",function(res){
					console.log('dept',dept);
					if(dept != null){
						parent.getChildValue(dept); // 调用父页面获取子页面的值
						parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
					}else{
						layer.msg('请选择部门');
					}
				})

			})
			
			
			
		</script>
	</body>
</html>
